package com.chg.mymvc.util;

import java.util.List;

public class Page {
    public Page() {
    }

    public Page(int pageNum, int pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    //当前页数
    private int pageNum;
    //每页条数
    private int pageSize;
    //总记录数
    private int total;
    //总页数
    private int pages;
    //上一页
    private int prePage;
    //下一页
    private int nextPage;
    //是否为首页
    private boolean firstPage;
    //是否为末页
    private boolean lastPage;
    //起始偏移量
    private int offset;
    //当前页数据
    private List list;

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPages() {
        return getTotal()%getPageSize()==0 ? getTotal()/getPageSize() : getTotal()/getPageSize()+1;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public int getPrePage() {
        return getPageNum()-1>=1 ? getPageNum()-1 : 1;
    }

    public void setPrePage(int prePage) {
        this.prePage = prePage;
    }

    public int getNextPage() {
        return getPageNum()+1<=getPages() ? getPageNum()+1 : getPages();
    }

    public void setNextPage(int nextPage) {
        this.nextPage = nextPage;
    }

    public boolean isFirstPage() {
        return getPageNum()==1;
    }

    public void setFirstPage(boolean firstPage) {
        this.firstPage = firstPage;
    }

    public boolean isLastPage() {
        return getPageNum()==getPages();
    }

    public void setLastPage(boolean lastPage) {
        this.lastPage = lastPage;
    }

    public int getOffset() {
        return (getPageNum() - 1) * getPageSize();
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public List getList() {
        return list;
    }

    public void setList(List list) {
        this.list = list;
    }

}
